import type { CaseHistory, CaseHistoryForm } from './model';

import type { ID, PageQuery, PageResult } from '#/api/common';

import { requestClient } from '#/api/request';

enum Api {
  caseHistoryDetail = '/userMedical/v1/getUserMedical',
  caseHistoryList = '/userMedical/v1/pageList',
  caseHistoryRemove = '/userMedical/v1/remove',
  caseHistorySave = '/userMedical/v1/save',
  caseHistoryUpdate = '/userMedical/v1/update',
}

/**
 * 病例管理分页列表
 * @param data 请求参数
 * @returns 列表
 */
export function caseHistoryList(data?: PageQuery) {
  return requestClient.post<PageResult<CaseHistory>>(Api.caseHistoryList, data);
}

/**
 * 新增病例
 * @param data 参数
 */
export function caseHistoryAdd(data: CaseHistoryForm) {
  return requestClient.postWithMsg<void>(Api.caseHistorySave, data);
}

/**
 * 更新病例
 * @param data 参数
 */
export function caseHistoryUpdate(data: CaseHistoryForm) {
  return requestClient.postWithMsg<void>(Api.caseHistoryUpdate, data);
}

/**
 * 获取病例详情
 * @param id 病例ID
 */
export function caseHistoryDetail(id: ID) {
  return requestClient.get<CaseHistory>(`${Api.caseHistoryDetail}`, {
    params: {
      id,
    },
  });
}

/**
 * 删除病例
 * @param id 病例ID
 */
export function caseHistoryRemove(id: ID) {
  return requestClient.get<void>(`${Api.caseHistoryRemove}`, {
    params: {
      id,
    },
  });
}
